package com.xishu.bo.printer;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 打印机一行的内容
 * <p>
 * 一行最多X列
 */
public class PrinterLine implements Serializable {
    private static final long serialVersionUID = 5753401825226214402L;

    private List<PrinterItem> itemList = new ArrayList<>();

    private boolean newLine = true;

    @ApiModelProperty(value = "直接拼接内容")
    private Boolean direct;

    public Boolean getDirect() {
        return direct;
    }

    public void setDirect(Boolean direct) {
        this.direct = direct;
    }

    public boolean isNewLine() {
        return newLine;
    }

    public void setNewLine(boolean newLine) {
        this.newLine = newLine;
    }

    public List<PrinterItem> getItemList() {
        return itemList;
    }

    public void setItemList(List<PrinterItem> itemList) {
        this.itemList = itemList;
    }

    public void add(PrinterItem printerItem) {
        itemList.add(printerItem);
    }

    /**
     * 只有一个元素的时候使用
     *
     * @return
     */
    public PrinterItem getPrinterItem() {
        return itemList.get(0);
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("PrinterLine{");
        sb.append("itemList=").append(itemList);
        sb.append(", newLine=").append(newLine);
        sb.append('}');
        return sb.toString();
    }
}
